<meta charset="utf-8" />
<meta http-equiv="Cache-Control" content="no-store" />
<div class="container-fluid">

	<div class="row">
		<div style="margin-bottom: 20px"></div>
		<div class="panel panel-primary">
			<div class="panel-heading">
				<div class="panel-title">Agenda</div>
			</div>
			<div class="panel-body">
				
				<section>
					<div class="col-xs-3">
						<input type="text" ng-model="search" class="form-control"
							placeholder="Pesquisar" />
					</div>
					
					<div class="col-xs-3">
  <select class="form-control"  ng-model="filtro.status" ng-change="filtrar(filtro.status)">
   
     <option value="" selected>Selecione...</option>
     <option  value="A" >Agendado(os)</option>
     <option  value="I" >Iniciado(os)</option>
     <option  value="T" >Terminado(os)</option>
     <option  value="todos" >Ver Todos</option>
  </select>
					</div>


					<button ng-click="abrirCadastroProjeto()"
						class="btn btn-primary pull-right">
						<span class="glyphicon glyphicon-plus"></span> Agendar Projeto
					</button>
				</section>

			</div>
			
			<div class="table-responsive">
			<table ng-table="tableParams" class="table">

				<thead>
					<tr>
						<th>#</th>
                        <th>Descrição</th>
                        <th>Tipo de folha</th>
                        <th>valor</th>
                        <th>Data de Recebimento</th>
                        <th>Data de Início</th>
                        <th>Data de Entrega</th>
                        <th>Iniciar</th>
                        <th>Finalizar</th>
                        <th>Status</th>
                        <th>Ações</th>
						
					</tr>
				</thead>
				<tbody>
				
      
   
	<tr ng-repeat="item in agendaPorStatus | filter: search"  ng-if="filtro.status == item.status || filtro.status != null">
        <td>{{ $index + 1 }}</td>
         <td>{{ item.descricao }}</td>
        <td>{{ item.folha.tipoFolha }}</td>
        <td>{{ item.folha.valor | currency }}</td>
        <td>{{ item.dataRecebimento }}</td>
        <td> <span  ng-class="{'glyphicon glyphicon-ok':item.dataInicio!='Invalid date', 'glyphicon glyphicon-warning-sign':item.dataInicio=='Invalid date'}" ></span>{{ item.dataInicio }}</td>
        <td><span  ng-class="{'glyphicon glyphicon-ok':item.dataEntrega!='Invalid date', 'glyphicon glyphicon-warning-sign':item.dataEntrega=='Invalid date'}"></span>{{ item.dataEntrega }}</td>
        <td><input ng-class="{'hidden-check-iniciado':item.status=='I', 'hidden-check-terminado':item.status=='T'}"   type="checkbox" ng-model="iniciar"  ng-change="iniciarProjeto(item.id, iniciar)" /></td>
        <td ><input ng-class="{'hidden-check-agendado':item.status=='A', 'hidden-check-terminado':item.status=='T'}" type="checkbox" ng-model="finalizar" ng-change="finalizarProjeto(item, finalizar, item.id)"  /></td>
       
        
        
         <td >{{item.status}}<span  ng-class="{'glyphicon glyphicon-ok':item.status=='T', 'glyphicon glyphicon-warning-sign':item.status=='A', 'fa fa-eye':item.status=='I'}" ></span></td>
      


						<td><a ng-href="#/projeto-ver/{{item.id}}"
							class="btn btn-default btn-xs"><i class="fa fa-eye"></i></a> 
                              <a class="btn btn-primary btn-xs" ng-href="#/editar-agenda/{{ item.id }}"><i class="fa fa-edit"></i></a>
                        <a ng-href="" ng-click="excluir(item.id, item)"  class="btn btn-danger btn-xs"><i class="fa fa-trash-o"></i></a>
                        </td>
					</tr>
				</tbody>
				 <tr><td><b>Total: </b> {{ somaPorStatus | currency }}</td></tr>
			</table>
			</div>
		</div>

	</div>
	
	

<script type="text/ng-template" id="add_projeto_modal">
    <div class="modal-header">
		<button class="btn btn-primary btn-xs pull-right" ng-click="cancel()"><i class="fa fa-times"/></button>
    
        <h3>Agendar Projeto</h3>
	
	</div>
    <div class="modal-body">
        <!--<alert ng-repeat="alert in alerts" type="alert.type" close="closeAlert($index)">{{alert.msg}}</alert>-->
        <form name="clienteForm" class="form-horizontal" ng-submit="add()">
            <div class="control-group">
                <label class="control-label" for="nome">Descrição</label>
                <div class="controls">
                    <input id="nome" name="nome"  ng-model="projeto.descricao" type="text" placeholder="Nome" class="form-control" ng-required="true"  ng-class="{error: user.name.$invalid && !user.name.$pristine}"/>
                </div>
            </div>

            <div class="control-group" >
                <label class="control-label" for="telefone">Tipo da folha</label>
                <div class="controls">
          <select id="produto"  ng-model="projeto.idFolha" ng-change="pegarId()" class="form-control" required>
            <option  ng-repeat="item in folhas" value="{{item.id}}" ng-bind="item.tipoFolha"> </option>
            <option value="" selected>Selecione...</option>

         </select>
</div>
            </div>

            <div class="control-group" >
                <label class="control-label" for="email">Valor</label>
                <div class="controls">
                    <input id="email" name="email" ng-model="usuario.email" type="hidden" placeholder="E-mail" class="form-control" ng-required="true" />
            <span class="form-control">{{ folha.valor | currency }}</span> 
                </div>
            </div>

          <div class="control-group" >
                <label class="control-label" for="email">Data de recebimento</label>
                <div class="controls">
                  <input type="date" class="form-control " id="txtSenha" name="senha"  required placeholder="Data de Recebimento" ng-model="projeto.dataRecebimento""/>
                </div>
            </div>


            <div class="control-group" >
                <br/>
                <div class="pull-right">
                    
                   
                    <button type="submit" class="btn btn-primary"><i class="fa fa-save"></i> Adicionar</button>

                    <button type="button" ng-click="cancel()" class="btn btn-danger"><i class="glyphicon glyphicon-remove"></i> Cancelar</button>
                </div>


            </div>

        </form>
    </div>
    <br/>
    <br/>
</script>
